package td3.model;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.File;

public class AppModel {

	private Contact currentContact = null;
	private ContactTreeModel contactTreeModel;
	private File currentFile;
	
	public enum Property {
		CONTACT_TREE_MODEL, CURRENT_CONTACT, CURRENT_FILE
	}

	private PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(
			this);

	public AppModel(ContactTreeModel contactTreeModel) {
		super();
		this.contactTreeModel = contactTreeModel;
	}

	public void addPropertyChangeListener(PropertyChangeListener listener) {
		propertyChangeSupport.addPropertyChangeListener(listener);
	}

	public void removePropertyChangeListener(PropertyChangeListener listener) {
		propertyChangeSupport.removePropertyChangeListener(listener);
	}

	public ContactTreeModel getContactTreeModel() {
		return contactTreeModel;
	}

	public void setContactTreeModel(ContactTreeModel contactTreeModel) {
		ContactTreeModel oldContactTreeModel = this.contactTreeModel;
		this.contactTreeModel = contactTreeModel;
		propertyChangeSupport.firePropertyChange(
				Property.CONTACT_TREE_MODEL.name(), oldContactTreeModel,
				contactTreeModel);
	}

	public Contact getCurrentContact() {
		return currentContact;
	}

	public void setCurrentContact(Contact currentContact) {
		Contact oldCurrentContact = this.currentContact;
		this.currentContact = currentContact;
		propertyChangeSupport.firePropertyChange(Property.CURRENT_CONTACT.name(), oldCurrentContact, currentContact);
	}

	public File getCurrentFile() {
		return currentFile;
	}

	public void setCurrentFile(File currentFile) {
		File oldFile = this.currentFile;
		this.currentFile = currentFile;
		propertyChangeSupport.firePropertyChange(Property.CURRENT_FILE.name(), oldFile, currentFile);

	}


	
}
